package com.practices.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.view.Window;
import android.view.WindowManager;

public class WindowDialog extends Activity {
	
	
//	
//	// 解锁
//	KeyguardManager manager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
//	if( manager.inKeyguardRestrictedInputMode() ){
//	    //处于锁定界面,界面则通过KeyguardLock类方法来解锁
//	    KeyguardLock keyguard = manager.newKeyguardLock(getLocalClassName());
//	    keyguard.disableKeyguard();
//	}
	
	
//	private static final String TAG = "pm";
//	PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
//	PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK| PowerManager.ON_AFTER_RELEASE,TAG);
//		wl.acquire();
//// ... do work...
//		wl.release();

	
	
//	//点亮屏幕
//	PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
//	mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.SCREEN_DIM_WAKE_LOCK, "SimpleTimer");
//	mWakelock.acquire();
//	//.......
//	mWakelock.release();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE); // hide title
		Window win = getWindow();
		WindowManager.LayoutParams winParams = win.getAttributes();
		winParams.flags |= (WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
		setRequestedOrientation(0);
	}

	@Override
	protected void onPause() {
		super.onPause();
//		releaseWakeLock()
	}
//    private void releaseWakeLock() {
//        if (mWakelock != null && mWakelock.isHeld()) {
//            mWakelock.release();
//            mWakelock = null;
//     }

	@Override
	protected void onResume() {
		super.onResume();
//		acquireWakeLock();
	}

//	private void acquireWakeLock() {
//         if (mWakelock == null) {
//             Log.i(TAG, "Activity begin start ");
//             PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
//             mWakelock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,     this.getClass().getCanonicalName());
//             mWakelock.acquire();
//    }

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}

}
